<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <router-link to='/'>首页功能</router-link>
        <router-link to='/category/1'>分类1</router-link>
        <router-link to='/category'>分类2</router-link>
        <router-link to='/'></router-link>
        <router-view></router-view>
    </div>
</body>
<script src="../lib/vue.js"></script>
<script src="./lib/vue-router.js"></script>
<script>
    var Index = {
        template: `<div>首页功能</div>`
    }
    var Category = {
        template: `<div>{{ $route.params.id }}</div>`
    }

    var router = new VueRouter({
        routes: [
            {
                path: '/',
                component: Index
            },
            {
                path: '/category/:id',
                component: Category
            },
            {
                path: '/category',
                redirect: '/'
            },
        ]
    });
    new Vue({
        el: "#app",
        router
    })
</script>

</html>